# $Id$
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org
# Contributor: Pierre Schmitz <pierre@archlinux.de>

# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - patch to fix unclickable plasmoid buttons on ARM

pkgname=kdelibs
pkgver=4.14.12
_kdeappver=15.08.1
pkgrel=1
pkgdesc="KDE Core Libraries"
arch=('i686' 'x86_64')
url='https://projects.kde.org/projects/kde/kdelibs'
license=('GPL' 'LGPL' 'FDL')
depends=('attica-qt4' 'libxss' 'krb5' 'qca' 'libdbusmenu-qt4' 'polkit-qt4'
        'shared-mime-info' 'enchant' 'giflib' 'jasper' 'openexr' 'strigi'
        'docbook-xsl' 'upower' 'udisks2' 'libxcursor' 'phonon-qt4'
        'media-player-info' 'libxtst' 'libutempter' 'qtwebkit' 'icu')
makedepends=('cmake' 'automoc4' 'avahi' 'libgl' 'hspell' 'mesa' 'grantlee-qt4')
install=${pkgname}.install
source=("http://download.kde.org/stable/applications/${_kdeappver}/src/${pkgname}-${pkgver}.tar.xz"
        'kde-applications-menu.patch' 'archlinux-menu.patch' 'qt4.patch'
        'arm-coronaoffscreen-input-fixes.diff')
sha1sums=('4e2fc81f0a21c15399e060943b6179c449e866d2'
          '86ee8c8660f19de8141ac99cd6943964d97a1ed7'
          '63a850ab4196b9d06934f2b4a13acd9f7739bc67'
          'ed1f57ee661e5c7440efcaba7e51d2554709701c'
          '855150096763600c970aa307c8241b96da33b9ed')

prepare() {
       mkdir -p build
       cd ${pkgname}-${pkgver}
       # avoid file conflict with gnome-menus
       patch -p1 -i "${srcdir}"/kde-applications-menu.patch
       # add Archlinux menu entry
       patch -p1 -i "${srcdir}"/archlinux-menu.patch
       # qmake refers to Qt5
       patch -p1 -i "${srcdir}"/qt4.patch
       # fix unclickable plasmoid buttons on ARM
       patch -p1 -i "${srcdir}"/arm-coronaoffscreen-input-fixes.diff
}

build() {
       cd build
       cmake ../${pkgname}-${pkgver} \
               -DCMAKE_BUILD_TYPE=Release \
               -DKDE4_BUILD_TESTS=OFF \
               -DCMAKE_SKIP_RPATH=ON \
               -DKDE_DISTRIBUTION_TEXT='Arch Linux' \
               -DCMAKE_INSTALL_PREFIX=/usr \
               -DSYSCONF_INSTALL_DIR=/etc \
               -DLOCALE_INSTALL_DIR=/usr/share/locale/kde4 \
               -DKDE_DEFAULT_HOME='.kde4' \
               -DWITH_FAM=OFF \
               -DWITH_SOLID_UDISKS2=ON
       make
}

package() {
       cd "${srcdir}"/build
       make DESTDIR="${pkgdir}" install

       # cert bundle seems to be hardcoded
       # link it to the one from ca-certificates
       rm -f "${pkgdir}"/usr/share/apps/kssl/ca-bundle.crt
       ln -sf /etc/ssl/certs/ca-certificates.crt "${pkgdir}"/usr/share/apps/kssl/ca-bundle.crt
}
